#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<vector>
#include<string>
#include<string.h>
using namespace std;
int main()
{
	int size = 0, flag1 = 1, flag2 = 1;
	vector<string> s;
	cin >> size;
	s.resize(size + 1);
	for (int i = 0; i < size; i++)
	{
		cin >> s[i];
	}
	for (int i = 1; i < size; i++)
	{
		if (strcmp(s[i - 1].c_str(), s[i].c_str()) > 0)
		{
			flag1 = 0;
		}
		if (s[i - 1].size() > s[i].size())
		{
			flag2 = 0;
		}
	}
	if (flag1 && !flag2)
	{
		cout << "lexicographically" << endl;
	}
	else if (!flag1 && flag2)
	{
		cout << "lengths" << endl;
	}
	else if (flag1 && flag2)
	{
		cout << "both" << endl;
	}
	else
	{
		cout << "none" << endl;
	}
	return 0;
}